package com.chuyangc.qdms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chuyangc.qdms.entity.Transport;
import com.chuyangc.qdms.service.TransportService;
import com.chuyangc.qdms.mapper.TransportMapper;
import com.chuyangc.qdms.vo.LogrecVO;
import com.chuyangc.qdms.vo.TransVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 欧楚杨
* @description 针对表【transport】的数据库操作Service实现
* @createDate 2022-06-01 00:04:36
*/
@Service
public class TransportServiceImpl extends ServiceImpl<TransportMapper, Transport>
    implements TransportService{
    @Autowired
    TransportMapper transportMapper;

    /**
     * @return List<Transport>
     * @method 获取处于发货中状态的日志记录
     */
    @Override
    public List<Transport> getTransporttypesend() {
        return transportMapper.getAllByTransporttype(1);
    }

    /**
     * @return List<Transport>
     * @method 获取处于送货中状态的日志记录
     */
    @Override
    public List<Transport> getTransporttypetrans() {
        return transportMapper.getAllByTransporttype(2);
    }

    /**
     * @return List<Transport>
     * @method 获取处于已签收状态的日志记录
     */
    @Override
    public List<Transport> getTransporttyperecie() {
        return transportMapper.getAllByTransporttype(3);
    }

    /**
     * @method 不同物流状态下的记录数统计
     * @return TransVO
     */
    @Override
    public TransVO getCount(){
        TransVO transVO = new TransVO();
        ArrayList<String> names = new ArrayList<>();
        names.add("发货中");
        names.add("送货中");
        names.add("已签收");
        ArrayList<Integer> values = new ArrayList<>();
        int sendnum = transportMapper.countByTransporttype(1);
        int transnum = transportMapper.countByTransporttype(2);
        int recienum = transportMapper.countByTransporttype(3);
        values.add(sendnum);
        values.add(transnum);
        values.add(recienum);
        transVO.setNames(names);
        transVO.setValues(values);
        transVO.setTotal(transportMapper.count());
        return transVO;
    }
}




